package com.javaee.exep3.controller;

import com.javaee.exep3.entity.RegionStatsVO;
import com.javaee.exep3.service.COVID19MsgService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * @author: lzh
 */
@Controller
public class COVID19MsgController {

    @Autowired
    COVID19MsgService covid19MsgService;

    @GetMapping("/")
    public String getCovid19Msg(Model model,  @RequestParam(required = false) String country) {
        RegionStatsVO covid19Msg = covid19MsgService.getCovid19Msg(country);
        model.addAttribute("covid19Msg", covid19Msg);
        return "index";
    }
}
